package vashion.azeroth.api.controller.tran;

import java.util.Date;
import java.util.List;

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import vashion.azeroth.api.controller.base.BaseController;
import vashion.azeroth.core.personal.tran.pojo.PersonalTranDetail;
import vashion.azeroth.core.result.ApiResult;
import vashion.azeroth.core.service.tran.PersonalTranDetailService;

@Controller
@RequestMapping("tran")
public class QueryVAccountDetailController extends BaseController {
	
	@Autowired
	private PersonalTranDetailService<PersonalTranDetail> tranDetailService;

	@RequestMapping("queryVDetail")
	@ResponseBody
	public ApiResult<List<PersonalTranDetail>> queryVAccountDetail(PersonalTranDetail tranDetail) {
		
		if(!StringUtils.isBlank(tranDetail.getTimeType())) {
			tranDetail.setTimeAdd(DateUtils.addMonths(new Date(), -1*Integer.valueOf(tranDetail.getTimeType())));
		} else {
			tranDetail.setTimeAdd(DateUtils.addMonths(new Date(), -1));
		}
		
		return tranDetailService.queryTranDetail(tranDetail);
	}
	
}
